#include"test.h"
#include<iostream>
#include"c3pom/Portal.h"
#include<unistd.h>
using namespace std;

test::test()
{
}

void test::run()
{
	int i=0;
	map<string,Object> m;
	m["owner"]=this;
	m["desc"]=*(new string("this is a test portal(这是一个测试portal)"));
	m["Portal_Buf_class"]="queue";
	attribute["portal_instance:c3pom.other.test"]=m;
	Portal p=attribute["kernel_instance"].castto<Kernel*>()->regportal("c3pom.other.test",m);//注册一个新的名称为c3pom.other.test的portal
	while(true)
	{  
		Portal_Block pb;
		Portal_Block pbk;
		pb["test"]=*(new string("what the fuck"+i++));
		//p<<pb;
		cout<<"......"<<endl;
		p>>pbk;
		Object o=pbk["test"];
		if(!o.isnull())
		{
			cout<<"recevied data:"<<o.castto<string>()<<endl;
		}
		else
		{
			cout<<"recevied nothing"<<endl;
		}
		sleep(1);
	} 
}

